export http_proxy="http://xx.xx.xx.xx:xxxx"
export https_proxy="http://xx.xx.xx.xx:xxxx"
export no_proxy=127.0.0.1,.huawei.com,localhost,local,.local


echo "============================================ prepareing environment ============================================="
source /root/.bashrc
conda activate mstestpy310
source /home/xxx/pckg/rc4b080/ascend-toolkit/set_env.sh
source /home/xxx/pckg/rc4b080/nnal/atb/set_env.sh


echo "============================================ prepareing megatron code ==========================================="
rm -rf Megatron-LM_last
mv Megatron-LM_now Megatron-LM_last
# cp -rf Megatron-LM_100 Megatron-LM_last
rm -rf Megatron-LM
git clone https://github.com/NVIDIA/Megatron-LM.git
# cp -rf Megatron-LM_bk Megatron-LM
cp -rf Megatron-LM Megatron-LM_now


echo "============================================ prepareing mindspeed code =========================================="
rm -rf MindSpeed
git clone https://gitee.com/ascend/MindSpeed.git
# cp -rf MindSpeed_bk MindSpeed


echo "============================================ checking megatron update ==========================================="
dt=$(date '+%Y%m%d')
python check_mgut_update.py Megatron-LM_last Megatron-LM tests/unit_tests "./logs/mg_update/ut_chgs_$dt.txt"
cp -rf ./logs/mg_update/ut_chgs_$dt.txt ./logs/mg_update/ut_chgs.txt
python check_mgut_update.py Megatron-LM_last Megatron-LM megatron "./logs/mg_update/mg_chgs_$dt.txt"
cp -rf ./logs/mg_update/mg_chgs_$dt.txt ./logs/mg_update/mg_chgs.txt
python check_args_update.py Megatron-LM_last Megatron-LM "./logs/mg_update/args_chgs_$dt.txt"
cp -rf ./logs/mg_update/args_chgs_$dt.txt ./logs/mg_update/args_chgs.txt


echo "============================================ running megatron unit test cases ==================================="
cp -rf MindSpeed/mindspeed ./Megatron-LM/
cp commands.yml exemgut.py ./Megatron-LM/
cd Megatron-LM

python exemgut.py


echo "============================================ parsing ut logs ===================================================="
cd ..

python utlogparse.py
